package jp.sourceforge.akjrcp.audiotools;

import jp.sourceforge.akjrcp.akj_betas.Messages;
import jp.sourceforge.akjrcp.ui.param.ParamItem;
import jp.sourceforge.akjrcp.ui.param.ParamItemActionListener;
import jp.sourceforge.akjrcp.ui.param.ParamRadioGroup;
import jp.sourceforge.akjrcp.ui.param.ParamTime;
import jp.sourceforge.akjrcp.util.TimeUtils;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

/*
 * still development?
 */
public class SubtitleMoveDialog extends  Dialog{
	
	long time;
	int direction=1;
	String title;
		public SubtitleMoveDialog(Shell parentShell, String dialogTitle) {
			super(parentShell);
			this.title=dialogTitle;
		}
		
		protected void configureShell(Shell newShell) {
			super.configureShell(newShell);
			newShell.setText(title);
		}
		
		  protected Control createDialogArea(Composite root) {
			  root.setLayout(new GridLayout(1,false));
			  final ParamRadioGroup plusMinus=new ParamRadioGroup(root,SWT.NULL,"direction",Messages.getString("srtmove.Direction"),new String[]{"minus","plus"},new String[]{Messages.getString("srtmove.left"),Messages.getString("srtmove.right")},2);
			  plusMinus.setParamItemActionListener(new ParamItemActionListener(){
				@Override
				public void paramItemModified(ParamItem item) {
					if(item.getValue().equals("minus")){
						direction=-1;
					}else{
						direction=1;
					}
				}});
			  plusMinus.setValue("plus");
			  final ParamTime timeParam=new ParamTime(root,SWT.NULL,"time",Messages.getString("srtmove.Time"),false,true,true,true);
			  timeParam.setValue(TimeUtils.toTimeText(time));
			  timeParam.addSelectionListener(new SelectionListener(){

				@Override
				public void widgetDefaultSelected(SelectionEvent e) {
					
				}

				@Override
				public void widgetSelected(SelectionEvent e) {
					time=timeParam.getTime();
				}});
		      return root;
		    }

		public long getTime() {
			return time;
		}

		public void setTime(long time) {
			this.time = time;
		}

		public int getDirection() {
			return direction;
		}

		public void setDirection(int direction) {
			this.direction = direction;
		}

	
	

	}
